home *** CD-ROM | disk | FTP | other *** search
- '--------------------------------------------------------------------------
- ' EnumWindows.vbs - Enumerates all open windows and prints window list
- ' to the standard output (when called from CSCRIPT).
- '
- ' This file is part of the sgWindow.
- ' Copyright (C) 1998 Stinga
- ' All rights reserved.
- '
- ' This sample demonstrates usage of the sgWindow component
- ' and it's window enumeration capabilities.
- '--------------------------------------------------------------------------
-
- option explicit
- dim vbCrLf
- vbCrLf = Chr(13) + Chr(10)
-
- ' --- Create window object
- dim g, wnd, sList
- Set g = CreateObject("SGWindow.Globals")
- Set wnd = g.DesktopWindow
-
- ' --- Collect window list
- sList = GetChildrenList(wnd, 0)
-
- WScript.Echo sList
- WScript.Echo "This list was generated with Stinga sgWindow component." + vbCrLf + "Copyright (C) 1998 Stinga"
-
- WScript.Quit
-
- ' --- Recursive function to collect window list
- Private Function GetChildrenList(wndParent, level)
- Dim wndChild, sPrefix
-
- sPrefix = Space(level * 2)
- For Each wndChild In wndParent.Children
- GetChildrenList = GetChildrenList + sPrefix + Hex(wndChild.HWND) + " - " + wndChild.Class + " - '" + wndChild.Text + "'" + vbCrLf
- GetChildrenList = GetChildrenList + GetChildrenList(wndChild, level + 1)
- Next
- End Function
-
-